﻿// CheckProjectListView.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "CheckProjectListView.h"


// CCheckProjectListView

IMPLEMENT_DYNCREATE(CCheckProjectListView, CListView)

CCheckProjectListView::CCheckProjectListView()
{
	m_bSubclassed = FALSE;
}

CCheckProjectListView::~CCheckProjectListView()
{
}

BEGIN_MESSAGE_MAP(CCheckProjectListView, CListView)
	ON_WM_SIZE()
	ON_WM_CREATE()
END_MESSAGE_MAP()


// CCheckProjectListView 诊断

#ifdef _DEBUG
void CCheckProjectListView::AssertValid() const
{
	CListView::AssertValid();
}

#ifndef _WIN32_WCE
void CCheckProjectListView::Dump(CDumpContext& dc) const
{
	CListView::Dump(dc);
}
#endif
#endif //_DEBUG


// CCheckProjectListView 消息处理程序

CListCtrl& CCheckProjectListView::GetListCtrl() const
{
	if (m_bSubclassed)
	{
		return (CCheckProjectListCtrl&)m_list; // 若子类化了，返回新的引用
	}
	else
	{
		return CListView::GetListCtrl(); // 若未子类化，调用默认处理
	}
}


void CCheckProjectListView::OnSize(UINT nType, int cx, int cy)
{
	CListView::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
}


void CCheckProjectListView::OnInitialUpdate()
{
	CListView::OnInitialUpdate();

	//// TODO: 在此添加专用代码和/或调用基类
	//CListCtrl& list = GetListCtrl(); // 得到CListCtrl对象的引用
	//HWND hwndListCtrl = list.m_hWnd; // 记录下它的句柄，下面马上会用到
	//list.UnsubclassWindow(); // 因为这个窗口已经是子类化过的（用Spy++可以看出来），要先进行UnsubclassWindow
	//m_list.SubclassWindow(hwndListCtrl); // 现在实现我的子类化
	//m_bSubclassed = TRUE; // 设置标志

	//// 下面这句很重要，否则很多API调用会认为CMyTreeView内部的控件窗口句柄无效
	//m_hWnd = m_list.m_hWnd; // 修正CMyTreeView的m_hWnd成员变量
}

void CCheckProjectListView::Populate()
{
	m_list.Populate();
}

int CCheckProjectListView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CListView::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  在此添加您专用的创建代码

	CRect rect;
	GetWindowRect(rect);
	DWORD dwStyle = WS_BORDER | LVS_ICON | LVS_ALIGNLEFT;

	BOOL ret = m_list.Create(dwStyle, rect, this, 0);
	if (!ret)
	{

	}
	m_list.AttachBitmap();
	m_list.Populate();

	return 0;
}
